﻿using CMS.BaseEntity;
using ElectronicSelling.DataAccess;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

namespace ElectronicSelling.BusinessLogic
{
    public class HomeProductLogic
    {
        public static DataTable GetMostViewed()
        {
            return HomeProductAccess.GetMostViewed();
        }

        public static DataTable GetNewProduct()
        {
            return HomeProductAccess.GetNewProduct();
        }

        public static DataTable GetNewProductList()
        {
            return HomeProductAccess.GetNewProductList();
        }

        public static DataTable GetMostViewList()
        {
            return HomeProductAccess.GetMostViewList();
        }

        public static DataTable GetPromotionProduct()
        {
            return HomeProductAccess.GetPromotionProduct();
        }

        public static DataTable GetPromotionProductList()
        {
            return HomeProductAccess.GetPromotionProductList();
        }

        /// <summary>
        /// Lấy product theo section =2 Electronic
        /// </summary>
        /// <returns></returns>
        public static DataTable GetElectronicProduct()
        {
            return HomeProductAccess.GetElectronicProduct();
        }

        /// <summary>
        /// Lấy product theo section =7 phone
        /// </summary>
        /// <returns></returns>
        public static DataTable GetSmartPhoneProduct()
        {
            return HomeProductAccess.GetSmartPhoneProduct();
        }

        /// <summary>
        /// Get Menu ngang
        /// </summary>
        /// <returns></returns>
        public static DataTable GetSection()
        {
            return HomeProductAccess.GetSection();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static DataTable GetCategoryBySection(Category category)
        {
            return HomeProductAccess.GetCategoryBySection(category);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static DataTable GetProductBySection(Product product)
        {
            return HomeProductAccess.GetProductBySection(product);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public static DataTable GetProductByCategory(Category category, Section section)
        {
            return HomeProductAccess.GetProductByCategory(category, section);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static string GetSectionById(Section section)
        {
            DataTable dt = HomeProductAccess.GetSectionById(section);
            if (dt.Rows.Count == 1)
            {
                DataRow dr = dt.Rows[0];
                return dr["SectionName"].ToString();
            }
            return null;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static string GetCategoryById(Category category)
        {
            DataTable dt = HomeProductAccess.GetCategoryById(category);
            if (dt.Rows.Count == 1)
            {
                DataRow dr = dt.Rows[0];
                return dr["CategoryName"].ToString();
            }
            return null;
        }

        /// <summary>
        /// Product Name by Id
        /// </summary>
        /// <returns></returns>
        public static string GetProductById(Product product)
        {
            DataTable dt = HomeProductAccess.GetProductById(product);
            if (dt.Rows.Count == 1)
            {
                DataRow dr = dt.Rows[0];
                return dr["Name"].ToString();
            }
            return null;
        }

        /// <summary>
        /// get detail product
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public static DataTable GetProductDetailById(Product product)
        {
            return HomeProductAccess.GetProductDetailById(product);
        }

        public static void UpdateVisited(Product product)
        {
            HomeProductAccess.UpdateVisited(product);
        }

        public static DataTable SearchProductAll(string value)
        {
            return HomeProductAccess.SearchProductAll(value);
        }
    }
}